package javase.stringDemo;

public class StringBuffer_StringBuilder_Demo {

    public static void main(String[] args) throws InterruptedException {
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < 100; i++){
            new Thread(() -> {
                for (int j = 0; j < 100; j++){
                    stringBuilder.append("a");
                }
            }).start();
        }

        Thread.sleep(100L);
        System.out.println("stringBuilder: " + stringBuilder.length());

        System.out.println("----------------------------------------");
        StringBuffer stringBuffer = new StringBuffer();
        for (int i = 0; i < 100; i++){
            new Thread(() -> {
                for (int j = 0; j < 100; j++){
                    stringBuffer.append("a");
                }
            }).start();
        }

        Thread.sleep(100L);
        System.out.println("StringBuffer: " + stringBuffer.length());
    }
}
